<template>
	<view>
		<!-- <uni-notice-bar :speed="25" scrollable single text="因密码在服务器中加密存储,所以密码需要抓包获取加密后的才能登录,请勿使用原密码进行登录"></uni-notice-bar> -->
			<!-- 账号 -->
		  <u-row customStyle="margin-bottom: 10px; margin-top: 30px" >
			  <u-col span="1"></u-col>
			  <u-col span="10">
				  <u--input placeholder="请输入学号" border="surround" maxlength="11" autoBlur v-model="user" prefixIcon="account" prefixIconStyle="font-size: 22px;color: #909399"></u--input>
			  </u-col>
			  <u-col span="1"></u-col>
		  </u-row>
		  			<!-- 密码 -->
		  <u-row customStyle="margin-bottom: 10px" >
			  <u-col span="1"></u-col>
			  <u-col span="10">
				  <u--input placeholder="请输入密码" maxlength="16" autoBlur border="surround" v-model="pwd" prefixIcon="lock-open" prefixIconStyle="font-size: 22px;color: #909399"></u--input>
			  </u-col>
			  <u-col span="1"></u-col>
		  </u-row>
		  <u-row customStyle="margin-bottom: 10px" v-show="false">
			  <u-col span="1"></u-col>
			  <u-col span="10">
				  <u--input placeholder="请输入sign(视情况而填)" autoBlur border="surround" v-model="sign" prefixIcon="tags" prefixIconStyle="font-size: 22px;color: #909399"></u--input>
			  </u-col>
			  <u-col span="1"></u-col>
		  </u-row>
		  <!-- 登录 -->
		  <u-row customStyle="margin-bottom: 20px" >
			  <u-col span="1"></u-col>
			  <u-col span="10">
				  <u-button text="登录" color="linear-gradient(to right, rgb(68, 125, 216), rgb(92, 137, 195))" @click="submit"></u-button>
			  </u-col>
			  <u-col span="1"></u-col>
		  </u-row>
		  
		  <u-row customStyle="margin-bottom: 10px">
			   <u-col span="1"></u-col>
			  <u-col span="8"><view class="tips-text" @click="loginToMsg">使用msg登录</view></u-col>
			  <u-col span="2">
				  <view class="tips-text"  @click="tips">必读公告</view>
			  </u-col>
			  <u-col span="1"></u-col>
		  </u-row>

	</view>
</template>

<script>
	import {mixin} from '../../../mixin.js'
	export default {
		data() {
			return {
				user:"",
				pwd:"",
				sign:""
			};
		},
		mixins:[mixin],
		onLoad(){		
			
		},
		methods:{
			loginToMsg(){
				uni.navigateTo({
					url:'./useMsgLogin'
				})
			},
			tips(){
				uni.navigateTo({
					url:'./tips'
				})
			},
			submit(){
				this.getDev()
				let pwds = this.getDes(this.pwd)
				//定义拼接字符串
				const params = {
					'account':this.user,
					'clientmark':uni.getStorageSync("dev"),
					'clienttype':"Android",
					'password':pwds,
					'schoolcode':"ccufe",
					'signtype':"SynSno"
				}
				uni.setStorageSync('sign',this.getMd5(this.getObjToStr(params)))
				//uni.setStorageSync("pwd",this.getDes(this.pwd))
				//console.log(uni.getStorageSync("pwd"))
				//console.log(uni.getStorageSync("sign"))
				uni.showLoading({
					title:"拼命登录中...",
					mask:true
				});
				uni.request({
					url:'http://ykt.ccufe.com:8070/Api/Account/SignIn',
					method:"POST",
					header:{
						//'User-Agent':'Dalvik/2.1.0 (Linux; U; Android 12; DBY-W09 Build/HUAWEIDBY-W09)',
						'Cache-Control':'no-cache',
						'Accept':'*/*',
						'Accept-Encoding':'gzip, deflate, br',
						'Connection':'keep-alive',
						//'cookie':'ASP.NET_SessionId=4xpnhnbiy1zviro0fsnh4xfb; path=/; HttpOnly; SameSite=Lax',
						'Content-Type':'application/x-www-form-urlencoded',
						'Content-Length':'154'
					},
					data:{
						'account':this.user,
						'clientmark':uni.getStorageSync("dev"),
						'clienttype':"Android",
						'password':pwds,
						'schoolcode':"ccufe",
						'signtype':"SynSno",
						'sign':uni.getStorageSync('sign')
					},
					//timeout:4000,
					success:res=>{
						console.log(res)
						if(res.data.success==true || res.data.success=="true"){
							
							this.userMsg = res.data.msg
							uni.setStorageSync("timeMsg",Number(new Date()))
							uni.setStorageSync("msg",res.data.msg)
							uni.setStorageSync("user",this.user)
							uni.setStorageSync("pwd",pwds)
							
							//uni.setStorageSync("sign",this.sign)
							uni.showToast({
								title:"登录成功"
							})
							uni.reLaunch({
								url:'../index'
							})
						}else if(res.data.success==false){
							uni.showToast({
								title:"某一项填写错误",
								position:'bottom'
							})
						}else{
							uni.showToast({
								title:"未知错误",
								position:'bottom'
							})
						}
						uni.hideLoading();
					},
					fail:err=>{
						uni.hideLoading();
					},
					complete:()=>{
						uni.hideLoading();
					}
				})
				///
			},
			
			
		}
	}
</script>

<style lang="scss">
	.tips-text{
		font-size: 30rpx;
		color:rgba(0, 0, 0, 0.7);
		margin-left: 0;
		
	}
</style>
